package com.ws.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ws.bean.MailRequest;
import com.ws.common.CommonResult;
import com.ws.service.SendMailService;
import com.ws.service.UserService;

import io.swagger.v3.oas.annotations.tags.Tag;

@RestController
@RequestMapping("/send-mail")
@Tag(name = "发送邮件接口", description = "用于发送邮件的相关操作")
public class SendMailController {
    @Autowired
    private SendMailService sendMailService;
    
    @Autowired
    UserService service;
    
    @PostMapping("/simple")
    public CommonResult SendSimpleMessage(@RequestBody MailRequest mailRequest) {
    	mailRequest.setText("你的初始密码是：123123  请登陆后尽快修改");
    	mailRequest.setSubject("初始密码");
    	service.setUser(mailRequest);
        sendMailService.sendSimpleMail(mailRequest);
        return CommonResult.success();
    }

    @PostMapping("/html")
    public void SendHtmlMessage(@RequestBody MailRequest mailRequest) { sendMailService.sendHtmlMail(mailRequest);}
}

